package com.csair.irp.job.file.parser.base;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @Auther: liaolonglong
 * @Date: 2018/12/18 16:21
 * @Description:
 */
@Service
public class FileManageService extends ServiceImpl<FileManageMapper, FileManagePO> {

    public FileManagePO getFileManageByPathAndFileName(String path, String fileName){
        LambdaQueryWrapper<FileManagePO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FileManagePO::getLink, path)
                .eq(FileManagePO::getFileName, fileName);
        return getOne(queryWrapper);
    }

    public int updateFileStateByID(FileManagePO.StateEnum stateEnum, Long fileId){
        FileManagePO fileManage = new FileManagePO();
        fileManage.setFileManageId(fileId);
        fileManage.setFileState(stateEnum.getCode());
        return baseMapper.updateById(fileManage);
    }
}
